Skip to content

[fix] Anthropic CUA triple_click mapping (#2104)#2107

Open
miguelg719 wants to merge 3 commits into
mainfrom
contrib/2104
Open

[fix] Anthropic CUA triple_click mapping (#2104)#2107
miguelg719 wants to merge 3 commits into
mainfrom
contrib/2104

Conversation

@miguelg719
Copy link
Copy Markdown
Collaborator

@miguelg719 miguelg719 commented May 11, 2026

Why

AnthropicCUAClient.convertToolUseToAction() handled actions like click, double_click, and left_click, but did not explicitly support triple_click.

Two issues:

  1. The action type remained in snake_case (triple_click) instead of being normalized to tripleClick — the format expected by v3CuaAgentHandler.executeAction().
  2. Coordinates provided via Anthropic’s coordinate: [x, y] format were not converted into the separate x / y fields required by the handler.

As a result, Anthropic triple-click actions were silently ignored by the handler switch.

What Changed

  • AnthropicCUAClient.ts

  • Added explicit handling for triple_click / tripleClick in convertToolUseToAction()

    • Mirrors the existing double_click implementation
    • Normalizes action type to tripleClick
    • Extracts coordinates from both:
      • coordinate: [x, y]
      • direct x / y fields
  • v3CuaAgentHandler.ts

    • Added "triple_click" as a switch-case alias in executeAction()

Test Plan

Added anthropic-cua-triple-click.test.ts (Vitest) covering:

  • triple_click with coordinate: [x, y]
  • triple_click with direct x / y fields

All existing unit tests continue to pass.


Summary by cubic

Fixes Anthropic CUA triple_click so it runs as tripleClick with x/y parsed from coordinate: [x, y] or explicit fields. Also adds a CI job to run evals unit tests.

  • Bug Fixes

    • Normalize triple_click/tripleClick to tripleClick in AnthropicCUAClient.convertToolUseToAction().
    • Parse x/y from coordinate: [x, y] or direct fields.
    • Add "triple_click" alias in v3CuaAgentHandler.executeAction().
  • Dependencies

    • Changeset to publish a patch for @browserbasehq/stagehand.

Written for commit a230bfc. Summary will update on new commits.

# Why

`AnthropicCUAClient.convertToolUseToAction()` handled actions like
`click`, `double_click`, and `left_click`, but did not explicitly
support `triple_click`.

Two issues:

1. The action type remained in snake_case (`triple_click`) instead of
being normalized to `tripleClick` — the format expected by
`v3CuaAgentHandler.executeAction()`.
2. Coordinates provided via Anthropic’s coordinate: [x, y] format were
not converted into the separate x / y fields required by the handler.

As a result, Anthropic triple-click actions were silently ignored by the
handler switch.

# What Changed

- AnthropicCUAClient.ts
- Added explicit handling for triple_click / tripleClick in
convertToolUseToAction()
  - Mirrors the existing double_click implementation
  - Normalizes action type to tripleClick
  - Extracts coordinates from both:
    - coordinate: [x, y]
    - direct x / y fields

- v3CuaAgentHandler.ts
  - Added "triple_click" as a switch-case alias in executeAction()

# Test Plan

Added `anthropic-cua-triple-click.test.ts` (Vitest) covering:

- triple_click with coordinate: [x, y]
- triple_click with direct x / y fields

All existing unit tests continue to pass.


<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fix incorrect handling of Anthropic CUA `triple_click` so triple-click
actions run and coordinates are parsed correctly. Adds unit tests for
both coordinate-array and x/y formats, and a changeset for a patch
release.

- **Bug Fixes**
- Normalize `triple_click`/`tripleClick` to internal `tripleClick` in
`AnthropicCUAClient`, extracting `x`/`y` from `coordinate` or explicit
fields.
- Add `"triple_click"` case to `V3CuaAgentHandler` so both naming styles
execute consistently.

- **Dependencies**
  - Add changeset to publish a patch for `@browserbasehq/stagehand`.

<sup>Written for commit 7a54548.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: a230bfc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server-v3 Patch
@browserbasehq/stagehand-server-v4 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@miguelg719 miguelg719 marked this pull request as ready for review May 11, 2026 20:58
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant CUA as Anthropic CUA API
    participant Client as AnthropicCUAClient
    participant Handler as V3CuaAgentHandler
    participant Browser as Browser Action Executor

    Note over CUA,Browser: Triple Click Action Mapping Flow

    CUA->>Client: tool_use: action="triple_click", input={coordinate=[x,y]}
    Client->>Client: convertToolUseToAction()
    Note over Client: Check action type
    alt action == "triple_click" || action == "tripleClick"
        Client->>Client: Extract coordinates from coordinate[] or direct x/y
        Client->>Client: Build action: {type:"tripleClick", x, y}
    end
    Client-->>Handler: executeAction({type:"tripleClick", x, y})

    Handler->>Handler: executeAction(action)
    alt action.type == "tripleClick" || action.type == "triple_click"
        Handler->>Handler: Parse x, y from action
        Handler->>Browser: Click(x, y, count=3)
        Browser-->>Handler: {success: true}
        Handler-->>Client: {success: true}
    end
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants